#include "Land.h"
//#include "Global.h"
#include "Resource.h"

CLand::CLand(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, LPD3DXSPRITE SpriteHandler, float x, float y) : Object(x, y)
{
	//_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\wallred.png"), 0, 0);
	//_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\Gach.png"), 0, 0);
	_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\Land.png"), 0, 0);
	//_sprite->SetFrame(4,5);
	//ResetRect();
	object_State = 1;
}

CLand::~CLand()
{
	/*if (_sprite != NULL)
	{
		delete _sprite;
	}*/
}

//void CLand::Init(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, LPD3DXSPRITE SpriteHandler)
//{
//	//_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\wallred.png"), 0, 0);
//	/*_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\Gach.png"), 0, 0);
//	ResetRect();*/
//
//}

void CLand::Update(int _ScreenWidth, int _ScreenHeight, float gameTime)// : Object::Update(_ScreenWidth, _ScreenHeight, gameTime)
{
	
	Object::Update(_ScreenWidth, _ScreenHeight, gameTime);
	//_sprite->Update(gameTime);
	ResetRect();
}

void CLand::Render()
{
	//Object::Draw(spriteHandler);
	/*float x = this->m_pos.x;
	float y = m_pos.y;*/
	//_sprite->SetFrame(0,1);
	//_sprite->SetFrame(4,5);
	//ResetRect();
	_sprite->Render(_x, _y);
}

OBJECT_TYPE CLand::GetTypeObject()
{
	return OBJECT_LAND;
}

void CLand::ResetRect()
{
	_rectBond.left = _x;
	_rectBond.right = _rectBond.left + _sprite->texture->_Width;
	_rectBond.top = _y;
	_rectBond.bottom = _rectBond.top + _sprite->texture->_Height;
}

void CLand::Update(list<Object*>* staObjs, list<Object*>* dynObjs, DxInput* input, float gameTime)
{
	//Object::Update(_ScreenWidth, _ScreenHeight, gameTime);
	//_sprite->Update(gameTime);
	ResetRect();
}